﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DeHeng_Mes.Mapper;
using DeHeng_Mes.Model.ConfigModel;
using DeHeng_Mes.Service;

namespace DeHeng_Mes.LineService
{
    public class SmallSecThreeProductionLine : IProductionLine
    {
        private readonly Dictionary<string, ProcessConfig> _processes;

        public SmallSecThreeProductionLine(DataCollector dataCollector)
        {
            _processes = new Dictionary<string, ProcessConfig>
            {
                { "SC3-1", new ProcessConfig { ProcessFunc = dataCollector.CollectDataForGluing, BatchSize = 0, InsertCount = 0,IsFirst = true, IsLast = false, IsUnique = false} },
                { "SC3-2", new ProcessConfig { ProcessFunc = dataCollector.CollectDataForGluingVision, BatchSize = 0, InsertCount = 0,IsFirst = true, IsLast = false, IsUnique = false} },
                { "SC3-3", new ProcessConfig { ProcessFunc = dataCollector.CollectDataForSpotWelding, BatchSize = 0, InsertCount = 0,IsFirst = false, IsLast = true, IsUnique = true} },
            };
        }
        // 公开一个只读属性供外部访问
        public IReadOnlyDictionary<string, ProcessConfig> Processes => _processes;

        // 实现 UniqueProcessCount 属性
        public int UniqueProcessCount => _processes.Values
            .Select(config => config.ProcessFunc.Method) // 按方法区分工艺种类
            .Distinct() // 去重
            .Count();
    }
}
